# @Author: Eric Ito
# @Date: 1/25/2009
# Project Euler problem 3

"""
What is the largest prime factor of 600851475143

ex. 13195 = 5,7,13,29
"""

import sys
from math import ceil

def isPrime(n):
	'''check if int n is a prime'''
	for x in range(2, int(n**0.5)+1):
		if n % x == 0:
			return False
	return True

def getFactors(n):
	FL = []
	x = 2
	while x < n/2:
		if n % x == 0:
			if x in FL:
				return FL
			FL.append(x)
			FL.append(n/x)
		x+=1
	return FL

def getLargestPrimeFactor(x):
	max = 0
	for i in x:
		if i > max and isPrime(i):
			max = i
	print max
	
def main():
	if len(sys.argv) == 2:
		FL = getFactors(int(sys.argv[1]))
		getLargestPrimeFactor(FL)
		#getLargestPrimeFactor(600851475143)
	else:
		print "must pass 1 arg"
		
if __name__ == '__main__':
	main()